fix: resolve index out of range panic in fetchContainerInfo for Ascend devices#95
Open
cygnushan wants to merge 1 commit into
Open
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: cygnushan The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @cygnushan! It looks like this is your first PR to Project-HAMi/HAMi-WebUI 🎉 |
7a7afe4 to
5e78963
Compare
…d devices - Pre-allocate bizContainerDevices based on actual container count to prevent out-of-bounds access when annotation device count differs from pod container count - Merge devices from all device types per container instead of overwriting, which previously caused device data loss for multi-device-type pods - Add container index boundary check in DecodePodDevices Ascend branch to align with NVIDIA/Hygon/Metax device handling Fixes Project-HAMi#94 Signed-off-by: handong <cygnushan@yunify.com>
5e78963 to
d1cd2c1
Compare
Author
|
Hi @archlitchi , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the
runtime error: index out of range [1] with length 1panic that occurs infetchContainerInfowhen scanning Pods using Ascend310P / AscendGPU devices.Previous PR #35 fixed the same symptom for NVIDIA/Hygon/Metax paths, but the Ascend branch in
DecodePodDeviceswas missed and still lacks the container-index boundary check.Root Cause
DecodePodDevices(Ascend path):strings.Split(str, OnePodMultiContainerSplitSymbol)may yield more segments than actual containers in the pod spec, causingPodSingleDevice(i.e.[]ContainerDevices) to be longer thanlen(pod.Spec.Containers).fetchContainerInfo: The old code blindly copied decoded devices into a slice and then indexed it with the container loop variable, triggering the panic when lengths mismatch.Changes
server/internal/data/pod.go: Pre-allocatebizContainerDevicesbased onlen(pod.Spec.Containers)and merge per-container devices with index guard (i < numContainers). Also fixes device data loss for multi-device-type pods by appending instead of overwriting.server/internal/provider/util/util.go: Addi >= len(pod.Spec.Containers) { break }guard and empty-segment handling (s == "") to theAscendGPUDevice / Ascend310PGPUDevicebranch, aligning it with NVIDIA/Hygon/Metax behavior.Related